﻿using BaseUI;
using BLL;
using Model;
using System;

namespace Thksoft.BusinessExpansion.Templete
{
    public partial class Upd_BasisSettings : BasePage
    {
        private Qs_Base_SetBLL qsb = new Qs_Base_SetBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Qs_Base_Set model = qsb.GetModelById(Request.QueryString["ID"].ToString());

                txtName.Value = model.Set_name;
                txtValue.Text = model.Set_value;
                txtRemark.Text = model.REMARK;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            Qs_Base_Set model = new Qs_Base_Set();

            if (string.IsNullOrEmpty(txtName.Value.ToString()))
            {
                MessageBox.Show(Page, "请输入设备名称");
                return;
            }
            if (string.IsNullOrEmpty(txtValue.Text))
            {
                MessageBox.Show(Page, "请输入设备值");
                return;
            }
            model.Set_name = txtName.Value.ToString();
            model.Set_value = txtValue.Text;
            model.REMARK = txtRemark.Text;
            model.Set_id = int.Parse(Request.QueryString["ID"].ToString());

            int count = qsb.UpdateModel(model, "");
            if (count > 0)
            {
                MessageBox.Show(Page, "保存成功");
                return;
            }
            else
            {
                MessageBox.Show(Page, "保存失败");
                return;
            }
        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            Response.Redirect("BasisSettings.aspx");
        }
    }
}